package main;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
/*
 * a window that allows a user to quit the game or return to the title after winning or losing
 */
public class ContinueWindow extends JFrame implements ActionListener {

	JButton Continue;
	JFrame parent;
	
	public ContinueWindow(boolean win, JFrame parent2) {
		parent = parent2;
		this.setSize(200, 120);
		
		this.setLayout(new FlowLayout());
		
		JLabel Status;
		JButton Quit;
		
		if (win) {
			Status = new JLabel("You've Won!");
			Continue = new JButton("Continue");
			Quit = new JButton("Quit");
		}
		else {
			Status = new JLabel("You've been defeated!");
			Continue = new JButton("Restart");
			Quit = new JButton("Quit");
		}
		
		Continue.addActionListener(this);
		Quit.addActionListener(this);
		
		add(Status);
		add(Continue);
		add(Quit);
		
		this.setVisible(true);
	}

	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == Continue) {
			parent.setVisible(true);
			this.setVisible(false);
		}
		else {
			System.exit(0);
		}
		
	}
	
}